package cn.kailangtu.myapplication.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 动作，（可扩展)
 */
public enum ActionCode {
    设置值(1),
    改图片(2),
    改底图(3),
    改底色(4),
    改字色(5),
    改显示(6),
    值匹配(7),
    自定义(8),
    声音(9);

    private final int value;
    ActionCode(int value)
    {
        this.value = value;
    }

    public int getValue(){
        return value;
    }

    private static final Map<Integer, ActionCode> CODE_MAP = new HashMap<>();

    static {
        for (ActionCode code : values()) {
            CODE_MAP.put(code.value, code);
        }
    }

    public static ActionCode fromValue(int value) {
        ActionCode code = CODE_MAP.get(value);
        if (code == null) {
            throw new IllegalArgumentException("无效的动作代码: " + value);
        }
        return code;
    }
}
